package fr.norsys.mapper.console.model;

import java.util.Collection;
import java.util.TreeSet;

import fr.norsys.mapper.console.utils.UIDGenerator;

public class Resource extends BaseObject {
	private static final long serialVersionUID = 4777176283483316246L;
	private String id;
	private String name;
	private String type;
	private String baseDn;
	private String filter;
	private String scope = "1";
	private String countLimit = "0";
	private String identifiant;
	private Collection attributes = new TreeSet(new AttributeNameComparator());
	
	public Resource() {
		super();
	}
	public Resource(String name) {
		super();
		this.id = UIDGenerator.generateId();
		this.name = name;
	}
	public Resource(String name, String type, String baseDn, Collection attributes) {
		super();
		this.id = UIDGenerator.generateId();
		this.name = name;
		this.type = type;
		this.baseDn = baseDn;
		this.attributes = attributes;
	}
	
	public Resource(String name,String baseDn,String identifiant, String type,String filter,String scope) {
		super();
		this.id = UIDGenerator.generateId();
		this.name = name;
		this.baseDn = baseDn;
		this.identifiant = identifiant;
		this.type = type;
		this.filter = filter;
		this.scope = scope;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	public Collection getAttributes() {
		return attributes;
	}
	public void setAttributes(Collection attributes) {
		this.attributes = attributes;
	}
	public String getBaseDn() {
		return baseDn;
	}
	public void setBaseDn(String baseDn) {
		this.baseDn = baseDn;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getFilter() {
		return filter;
	}
	public void setFilter(String filter) {
		this.filter = filter;
	}
	public String getScope() {
		return scope;
	}
	public void setScope(String scope) {
		this.scope = scope;
	}
	public void addAttribute(Attribute attribute) {
		if(attribute!=null && !"".equals(attribute.getId())) {
			attributes.add(attribute);
	}
	}
	public void deleteAttribute(Attribute attribute) {
		if(attribute!=null && !"".equals(attribute.getId())) {
			attributes.remove(attribute);
		}
	}
	public String getCountLimit() {
		return countLimit;
	}
	public void setCountLimit(String countLimit) {
		this.countLimit = countLimit;
	}
	public String getIdentifiant() {
		return identifiant;
	}
	public void setIdentifiant(String identifiant) {
		this.identifiant = identifiant;
	}
}